from typing import Optional

from pydantic import BaseModel, EmailStr, HttpUrl

from app.models.domain.users import User
from app.models.schemas.rwschema import RWSchema

from faker import Faker
fake = Faker("zh_CN")

# 登录用户所填信息
class UserInLogin(RWSchema):
    # email: EmailStr
    username: str
    password: str

# 注册用户所填信息
class UserInCreate(UserInLogin):
    username: Optional[str] = fake.name()
    email: Optional[EmailStr] = fake.email()
    # username: str
    # email: EmailStr

class UserInUpdate(BaseModel):
    username: Optional[str] = None
    email: Optional[EmailStr] = None
    password: Optional[str] = None
    bio: Optional[str] = None
    image: Optional[HttpUrl] = None

class UserWithToken(User):
    token: str

class UserInResponse(RWSchema):
    user: UserWithToken
